<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');
require_once ('../../simpletest/autorun.php');
require_once ('../lib/init.php');
require_once ('../data_sample/mockup_data_like.php');

class TestFunc_processMyLike extends UnitTestCase {
    
    function setUp(){
        global $login_button,$facebook;
        
        if(isLoggedIn()){
            try{
                $me = getOneself();
            }catch(Exception $e){
                print($login_button);
                exit();
            }
        }
    }
    
/////////////////////////
//MY LIKE CASES
//Case1: I liked a status of one of friends (regardless of where it is)
    function test_case1(){ 
        global $likeCase1;
        $data = $likeCase1;
        $friends = array();
        
        $flag = "MY_LIKE_ON_STATUS_FLAG";
        processMyLikeOnStatus($friends, $data, $flag);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 1);
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag),1);
    }
//    1.1: I liked statuses of one of friends (regardless of where it is)
    function test_case11(){ 
        global $likeCase11;
        $data = $likeCase11;
        $friends = array();

        $flag = "MY_LIKE_ON_STATUS_FLAG";
        processMyLikeOnStatus($friends, $data, $flag);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),1);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData($flag) == 2);
    }
//    1.2: I liked each status of two friends (regardless of where it is)
    function test_case12(){ 
        global $likeCase12;
        $data = $likeCase12;
        $friends = array();
        
        $flag = "MY_LIKE_ON_STATUS_FLAG";
        processMyLikeOnStatus($friends, $data, $flag);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData($flag) == 1);
        $friend = $friends['100000525262538'];
        $this->assertTrue($friend->getNumberOfData($flag) == 1);
    }
    
//    1.3: I liked statuses of two friends (regardless of where it is)
    function test_case13(){ 
        global $likeCase13;
        $data = $likeCase13;
        $friends = array();
        
        $flag = "MY_LIKE_ON_STATUS_FLAG";
        processMyLikeOnStatus($friends, $data, $flag);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData($flag) == 3);
        $friend = $friends['100000525262538'];
        $this->assertTrue($friend->getNumberOfData($flag) == 2);
    }
    
//Case2: I liked a link of one of friends (regardless of where it is)
    function test_case2(){ 
        global $likeCase2;
        $data = $likeCase2;
        $friends = array();
        
        $flag = "MY_LIKE_ON_LINK_FLAG";
        processMyLikeOnLink($friends, $data);

        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag),1);
    }    
//    2.1: I liked links of one of friends (regardless of where it is)
    function test_case21(){ 
        global $likeCase21;
        $data = $likeCase21;
        $friends = array();
        
        $flag = "MY_LIKE_ON_LINK_FLAG";
        processMyLikeOnLink($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),1);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData($flag) == 2);
    }  
//    2.2: I liked each link of two friends (regardless of where it is)
    function test_case22(){ 
        global $likeCase22;
        $data = $likeCase22;
        $friends = array();
        
        $flag = "MY_LIKE_ON_LINK_FLAG";
        processMyLikeOnLink($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData($flag) == 1);
        $friend = $friends['100000525262538'];
        $this->assertTrue($friend->getNumberOfData($flag) == 1);
    }  
//    2.3: I liked links of two friends (regardless of where it is)
    function test_case23(){ 
        global $likeCase23;
        $data = $likeCase23;
        $friends = array();
        
        $flag = "MY_LIKE_ON_LINK_FLAG";
        processMyLikeOnLink($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 3);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData($flag), 2);
    }  
//Case3: I liked a note of one of friends (regardless of where it is)
    function test_case3(){ 
        global $likeCase3;
        $data = $likeCase3;
        $friends = array();
        
        $flag = "MY_LIKE_ON_NOTE_FLAG";
        processMyLikeOnNote($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 1);
    } 
//    3.1: I liked notes of one of friends (regardless of where it is)
    function test_case31(){ 
        global $likeCase31;
        $data = $likeCase31;
        $friends = array();
        
        $flag = "MY_LIKE_ON_NOTE_FLAG";
        processMyLikeOnNote($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 2);
    } 
//    3.2: I liked each note of two friends (regardless of where it is)
    function test_case32(){ 
        global $likeCase32;
        $data = $likeCase32;
        $friends = array();
        
        $flag = "MY_LIKE_ON_NOTE_FLAG";
        processMyLikeOnNote($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 1);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData($flag), 1);
    } 
//    3.3: I liked notes of two friends (regardless of where it is)
    function test_case33(){ 
        global $likeCase33;
        $data = $likeCase33;
        $friends = array();
        
        $flag = "MY_LIKE_ON_NOTE_FLAG";
        processMyLikeOnNote($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 3);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData($flag), 2);
    } 
//Case4: I liked a photo of one of friends (regardless of where it is)
    function test_case4(){ 
        global $likeCase4;
        $data = $likeCase4;
        $friends = array();
        
        $flag = "MY_LIKE_ON_PHOTO_FLAG";
        processMyLikeOnPhoto($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 1);
    }
//    4.1: I liked photos of one of friends (regardless of where it is)
    function test_case41(){ 
        global $likeCase41;
        $data = $likeCase41;
        $friends = array();
        
        $flag = "MY_LIKE_ON_PHOTO_FLAG";
        processMyLikeOnPhoto($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 2);
    }
//    4.2: I liked each photo of two friends (regardless of where it is)
    function test_case42(){ 
        global $likeCase42;
        $data = $likeCase42;
        $friends = array();
        
        $flag = "MY_LIKE_ON_PHOTO_FLAG";
        processMyLikeOnPhoto($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 1);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData($flag), 1);
    }
//    4.3: I liked photos of two friends (regardless of where it is)
    function test_case43(){ 
        global $likeCase43;
        $data = $likeCase43;
        $friends = array();
        
        $flag = "MY_LIKE_ON_PHOTO_FLAG";
        processMyLikeOnPhoto($friends, $data);
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends), 2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData($flag), 3);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData($flag), 2);
    }
}
?>
